﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace DataLayer
{
    [KnownType(typeof(Movie))]
    [DataContract(IsReference = true)]
    public class Cinema
    {
        private string _name;
        private string _location;
        private List<Movie> _movies;

        /// <summary>
        /// Constructor taking 3 parameters
        /// </summary>
        /// <param name="name">Name of cinema</param>
        /// <param name="location">Location of cinema</param>
        /// <param name="movies">List of movies the cinema shows</param>
        public Cinema(string name, string location, List<Movie> movies)
        {
            Instanciate(name, location, movies);
        }

        /// <summary>
        /// Constructor taking 2 parameters
        /// </summary>
        /// <param name="name">Name of cinema</param>
        /// <param name="location">Location of cinema</param>
        public Cinema(string name, string location)
        {
            Instanciate(name, location, null);
        }

        /// <summary>
        /// Constructor taking 1 parameter
        /// </summary>
        /// <param name="name">Name of cinema</param>
        public Cinema(string name)
        {
            Instanciate(name, "", null);
        }

        /// <summary>
        /// Constructor taking no parameters
        /// </summary>
        public Cinema()
        {
            Instanciate("", "", null);
        }

        /// <summary>
        /// Set instans variables
        /// </summary>
        /// <param name="name">Name of cinema</param>
        /// <param name="location">Location of cinema</param>
        /// <param name="movies">List of movies the cinema shows</param>
        private void Instanciate(string name, string location, List<Movie> movies) 
        {
            _name = name;
            _location = location;
            _movies = Movies;
        }

        [DataMember]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        [DataMember]
        public string Location
        {
            get { return _location; }
            set { _location = value; }
        }

        [DataMember]
        public List<Movie> Movies
        {
            get { return _movies; }
            set { _movies = value; }
        }
    }
}
